package com.djmw.mouse.solr;

import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.djmw.mouse.Env;

@Component
public class SolrHelper {
    @Autowired
    Env env;

    public SolrServer getDefaultServer() {
        HttpSolrServer server = new HttpSolrServer(env.getSolrServer());
        server.setMaxRetries(1);
        server.setConnectionTimeout(3000);
        server.setParser(new XMLResponseParser());
        server.setSoTimeout(1000);
        // server.setDefaultMaxConnectionsPerHost(100);
        // server.setMaxTotalConnections(100);
        // server.setFollowRedirects(false);
        server.setAllowCompression(true);
        return server;
    }

}
